<?
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

require('includes/class.main.php');
$manager = new MeetingManager();
require('./includes/class.geocode.php');

if (isset($_POST['submit'])) {
	$address1		= $_POST['address1'];
	$city			= $_POST['city'];
	$zip			= $_POST['zip'];

	$result = GeocodeManager::geocodeLocation($address1, $city, $zip, $lat, $lng);

} else { 
	$address1 = "";
	$city = "";
	$zip = "";
	$lng = "-84.3879824";
	$lat = "33.7489954";

}

?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />  
  <link rel="stylesheet" href="../css/style.css" type="text/css" />
  <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<? echo googleMapKey(); ?>&sensor=false" ></script>
  
  <script type="text/javascript" src="../javascript/site.js"></script>
  <script type="text/javascript">

	
	function initialize() {

	  var latlng = 	new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng;?>);
	  var mapOptions = {
                center: latlng,
                zoom: 15
              };
       var map = new google.maps.Map(document.getElementById("map_canvas"),
                  mapOptions);
       var marker = new google.maps.Marker({
    	      position: latlng,
    	      map: map
    	  });
  	}

	google.maps.event.addDomListener(window, 'load', initialize);
  </script>
  
</head>

<body >
<div class="content">
	<?php 
	if (isset($result)) { 
		echo "<span style=\"color:red\">$result</span>";
	}
	?>
	<form  id="locationForm" action="location.php" method="post">
		<div class="adminForm" >
			
			<span class="label col1"><b>Address1</b></span>
			<input type="text" name="address1" style="width:28em" value="<?php echo $address1; ?>" />
			<br>
			<span class="col1 label" ><b>City</b></span>
			<input type="text" name="city" style="width:11.5em" value="<?php echo $city; ?>" />
			<span class="label" ><b>Zip</b></span>
			<input type="text" name="zip" style="width:4em" value="<?php echo $zip; ?>" />
			<br>
			<span class="label col1"><b>Lng</b></span>
			<input type="text" name="lng" style="width:11.5em" value="<?php echo $lng; ?>" />
			<br>
			<span class="col1 label" ><b>Lat</b></span>
			<input type="text" name="lat" style="width:11.5em" value="<?php echo $lat; ?>" />
			<br>
			
			<div class="submitBlock">
				<input type="submit" value="Geocode" name="submit" >
			</div>
		</div>
	</form>
	<br>
	<br>
	<div id="map_canvas" style="width: 500px; height: 300px; margin-right: 10px;"></div>
	
</div>
</body>
					
